package com.polytech.utils;

import com.polytech.business.DefaultForumManager;
import com.polytech.business.DefaultMembresManager;
import com.polytech.business.ForumManager;
import com.polytech.business.MembresManager;
import com.polytech.dao.MembreDao;
import com.polytech.dao.MembreDaoJdbc;
import com.polytech.dao.PostDao;
import com.polytech.dao.PostDaoJdbc;
import com.polytech.dao.TopicDao;
import com.polytech.dao.TopicDaoJdbc;

public class BusinessFactory {

	private static ForumManager forumManager;
	private static MembresManager membresManager;
	static{
		DataSource dataSource=new MySqlDataSource("sql330222", "sql3.freesqldatabase.com","sql330222","hZ1*yQ3*");
		Database database=new Database(dataSource);
		
		MembreDao membreDao=new MembreDaoJdbc(database);
		TopicDao topicDao=new TopicDaoJdbc(database,membreDao);
		PostDao postDao=new PostDaoJdbc(database);
		
		membresManager=new DefaultMembresManager();
		((DefaultMembresManager)membresManager).setMembreDao(membreDao);
		
		forumManager=new DefaultForumManager(topicDao, postDao);
	}
	public static ForumManager getForumManager() {
		return forumManager;
	}
	public static MembresManager getMembresManager() {
		return membresManager;
	}
	
}
